﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Text;

public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserName"] != null)
        {
            txtUserName.Value = Session["UserName"].ToString();
        }
        else
        {
            Whir.Common.WebHelper.JsHelper.redirect(this.Page, "请先登录!", "Default.aspx");
        }
    }

    protected string GetNewsList(int TypeID, int TopNum, int length)
    {
        string sql = "select top " + TopNum + " * from Whir_U_News where TypeID=" + TypeID + " or TypeID in (select ColumnID from Whir_Column where ParentId=" + TypeID + ") order by CreateDate desc";
        System.Text.StringBuilder sb = new StringBuilder();
        System.Data.DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sql).Tables[0];
        if (dt != null && dt.Rows.Count > 0)
        {
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                string title = dr["Title"].ToString();
                string id = dr["Whir_U_News_PID"].ToString();
                string _TypeID = dr["TypeID"].ToString();
                string CreateDate = Convert.ToDateTime(dr["CreateDate"].ToString()).ToString("MM-dd");
                sb.AppendFormat("<li><span>{3}</span><a   href=\"news_info.aspx?id={1}&mode=index&cid={2}\">" + Whir.Common.WebHelper.StringHelper.CutString(dr["Title"].ToString(), length) + "</a></li>", title, id, _TypeID, CreateDate);
            }
        }

        return sb.ToString();
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (txtNewPwd.Value != txtNewPwd1.Value)
        {
            Whir.Common.WebHelper.JsHelper.Alert(this.Page, "密码跟确认密码不一致，请重新输入！");
            return;
        }
        try
        {
            string sql = "update Whir_U_Users set MemberPwd='" + txtNewPwd.Value + "' where LoginName='" + txtUserName.Value + "'";
            int count = Whir.SQLServerDAL.DbHelperSQL.ExecuteSql(sql);
            Whir.Common.WebHelper.JsHelper.redirect(this.Page, "修改密码成功！", "login.aspx");
        }
        catch
        {
            Whir.Common.WebHelper.JsHelper.Alert(this.Page, "修改密码失败！");
        }

    }
}
